package cn.xlunzi.games.utils

/**
 * Created by SunLW on 2018-04-09.
 */
object NumUtil {

    fun getNumCN(num: Int): String {
        val list = listOf("一", "二", "三", "四", "五", "六", "七", "八", "九", "十")
        var result: String
        var position: Int = num
        when {
            num < 0 -> {
                result = "负"
                return result
            }
            num in 0..9 -> {
                result = ""
                position = num
            }
            num in 10..18 -> {
                result = "十"
                position = num - 10
            }
            num == 19 -> {
                result = "二"
                position = num - 10
            }
            num in 20..28 -> {
                result = "二十"
                position = num - 20
            }
            num == 29 -> {
                result = "三"
                position = num - 20
            }
            num in 30..38 -> {
                result = "三十"
                position = num - 30
            }
            else -> {
                result = "太大"
                return result
            }
        }
        result += list[position]
        return result
    }
}